<template>
  <div class="flex flexwrapper h_200">
    <div v-for="(item,index) in list" :key="index" class="item flexcenter commhover" @click='changeIcon(item)'>
      <div v-if="activeSrc == item.url" class="current">使用中</div>
      <img :src="item.img" alt="" class="itemimg" />
    </div>
  </div>
</template>
<script>
import { sourceBg,settingEdit } from "@/api/active";
export default {
  data() {
    return {
      list: [],
      activeSrc:''
    };
  },
  created() {
    this.activeSrc = this.src
    this.getList();
  },
  props:{
    activeId:{
      default:''
    },
    src:{
      default:''
    }
  },
  methods: {
    getList() {
      sourceBg().then((res) => {
        this.list = res.data.map(item=>({...item,img:process.env.VUE_APP_BASE_API + '/' + item.url}));
      });
    },

    changeIcon(item){
      this.activeSrc = item.url
      this.$emit('changeImg',{type:'bg_url',url:item.url})
    },
  },
};
</script>

<style lang="scss" scoped>
.h_200{
    height: 550px;
    overflow-y:auto
}
.item {
  background-color: #f5f5f5;
  width: 162px;
  height: 284px;
  border-radius: 6px;
  margin: 5px;
  position: relative;
  overflow: hidden;
}
.itemimg {
  width: 162px;
  height: 284px;
}
.current{
  position: absolute;
  left: -27px;
  top: -11px;
  background-color: #e91611;
  color: #fff;
  z-index: 2;
  font-size: 12px;
  text-align: center;
  padding: 15px 20px 0 20px;
  line-height: 30px;
  transform: rotate(-45deg);
}
</style>